Defining Contacts

If you are a contact programmer, you will use the defcontact macro to define a new contact class. The syntax of defcontact is nearly identical to that of the basic CLOS defclass macro. The only difference is the additional :resources option for specifying contact resources (see Section [*]).

(defcontact
  blinker                         ; Class name  
  (contact)                       ; Superclasses  
  ((color                         ; Slot specs, with name...
     :type     pixel              ; ...data type...
     :accessor blinker-color      ; ...accessor function name ...
     :initarg  :color             ; ...initarg keyword for make-contact...
     :initform 0)                 ; ...and default initial value.
   (on-p
     :type     boolean
     :accessor blinker-on-p
     :initform nil))  
  (:resources color))             ; Resource specs

A contact programmer must also define a display method for a new contact class. CLUE calls the display function automatically whenever any portion of the contact image must be (re)displayed. In particular, display is called whenever an invisible contact is changed to the :mapped state, or when some previously-hidden part of a :mapped contact is exposed.

(defmethod                        ; Define a method ...
  display                         ; ... for the display function...
  ((contact blinker)              ; ... when the contact arg is a blinker.
   &optional x y width height)    ; Defines the rectangular piece exposed.
  ...)